#输入变量空值检查
chkVars=ciContext imageUrl
$(foreach var,${chkVars},$(eval $(call var_notnull,${var})))

#私有变量定义
myRoot=${projectRoot}
myHomer=${HOMER}
myImgUrl=${imageUrl}
myContext=${ciContext}

#空值变量处理
myBuildImage?=cfxl/nodejs-alpine:14.18.2

#宏定义 start
define mvn_run_direct
yarn run $(1)
endef

define mvn_run_docker
docker run --rm -i -v ${myRoot}:${myRoot} -w ${myRoot} \
-v ${myHomer}/.node_modules:/node_modules \
--net host -e "https_proxy=${hp}" \
--entrypoint=/bin/sh ${myBuildImage} \
-c "if [ ! -d ./node_modules ]; then ln -s /node_modules ./node_modules; yarn install; fi; yarn $(1)"
endef

define runner =
$(call mvn_run_$(T),$(1))
endef
# end宏定义

.PHONY: depx
depx:
	@echo current have no depends need todo

.PHONY: buildx
buildx: #在容器中构建
	$(call runner,build)

.PHONY: imagex
imagex: entryx#基于构建二进制，构建镜像
	#@date > files/changer
	$(call func_build_image)

.PHONY: pushx
pushx: #推送镜像到仓库
	@$(call func_push_image)

.PHONY: testx
testx: #测试镜像
	docker run --rm -it  --net host ${myImgUrl}

.PHONY: cleanx
cleanx: #清空构建
	yarn clean